Character strings are not a special data type in the Calculator. Rather, a string is represented simply as a vector all of whose elements are integers in the range 0 to 255 (ASCII codes). You can enter a string at any time by pressing the " key. Quotation marks and backslashes are written ‘\"’ and ‘\\’, respectively, inside strings. Other notations introduced by backslashes are:
\a 7 \^@ 0
\b 8 \^a-z 1-26
\e 27 \^[ 27
\f 12 \^\\ 28
\n 10 \^] 29
\r 13 \^^ 30
\t 9 \^_ 31
\^? 127
Finally, a backslash followed by three octal digits produces any character from its ASCII code.
Strings are
normally displayed in vector-of-integers form. The
d "
(calc-display-strings) command toggles a mode in
which any vectors of small integers are displayed as quoted
strings instead.
The backslash notations shown above are also used for displaying strings. Characters 128 and above are not translated by Calc; unless you have an Emacs modified for 8-bit fonts, these will show up in backslash-octal-digits notation. For characters below 32, and for character 127, Calc uses the backslash-letter combination if there is one, or otherwise uses a ‘\^’ sequence.
The only Calc feature that uses strings is compositions; see Compositions. Strings also provide a convenient way to do conversions between ASCII characters and integers.
There is
a string function which provides a different display
format for strings. Basically, ‘string(s)’, where s is a vector of
integers in the proper range, is displayed as the corresponding
string of characters with no surrounding quotation marks or other
modifications. Thus ‘string("ABC")’ (or
‘string([65 66
67])’) will look like
‘ABC’ on the
stack. This happens regardless of whether d "
has been used. The only way to turn it off is to use
d U (unformatted language mode) which will display
‘string("ABC")’ instead.
Control characters are displayed somewhat differently by
string. Characters below 32, and character 127, are
shown using ‘^’ notation (same as shown above, but
without the backslash). The quote and backslash characters are
left alone, as are characters 128 and above.
The
bstring function is just like string
except that the resulting string is breakable across multiple
lines if it doesn't fit all on one line. Potential break points
occur at every space character in the string.